import { createSlice, createAsyncThunk } from '@reduxjs/toolkit'

export const appAsync = createAsyncThunk('yyy', () => {
  return new Promise<string>((resolve, reject) => {
    setTimeout(() => {
      resolve('en')
    }, 1000)
  })
})
export default createSlice({
  name: 'xxx',
  initialState: { lang: 'zh' },
  reducers: {
    setLang(state, action) {
      state.lang = action.payload
    },
  },

  extraReducers(builder) {
    builder.addCase(appAsync.fulfilled, (state, action) => {
      state.lang = action.payload
    })
  },
})
